import request from "@/utils/request"
type requestGetList ={
    id:number
    pageIndex:number
    pageSize:number
}
export type instantlist={
    id?:number
    userId?:number
    title:string
    context:string
    img:string
    likeNum?:number
    username:string
    created_at:string
    commentNum:number
    showFlag:boolean
    flag:boolean
    showLoading:boolean
}
export interface commentList{
    id?:number
    username:string
    userId:number
    created_at:string
    context:string
    instantId?:number
    parentId?:number
}
export type createCommentType={
    instantId:number
    parentId:number
    context:string
}
export interface commentList2 extends commentList {
    child:Array<commentList2>
    parentUserName?:string
    parentUserId:number
}
export type dataList = {
    list: Array<commentList2>
    count: number
}
export const getList=(data:requestGetList)=>{
    return request<dataList>({
        url:"/api/comment/list",
        method:"post",
        data
    })
}
export const getlistbyid=(data:Record<string,number>)=>{
    return request<instantlist>({
        url:"/api/instant/getlistbyid",
        method:"post",
        data
    })
}

export const createComment =(data:createCommentType)=>{
    return request({
        url:"/api/comment/create",
        method:"post",
        data
    })
}